// routes/jwtBlacklistRoutes.js
const express = require('express');
const router = express.Router();
const jwtBlacklistControll = require('../controllers/jwtBlacklistControll');

router.post('/blacklist', async (req, res) => {
  try {
    const { token } = req.body;
    const tokenId = await jwtBlacklistControll.addTokenToBlacklist(token);
    res.status(201).json({ tokenId });
  } catch (error) {
    res.status(500).json({ message: error.message });
  }
});

router.get('/isBlacklisted', async (req, res) => {
  try {
    const { token } = req.query;
    const isBlacklisted = await jwtBlacklistControll.isTokenBlacklisted(token);
    res.json({ isBlacklisted });
  } catch (error) {
    res.status(500).json({ message: error.message });
  }
});

module.exports = router;
